<template>
	<view class="page">
		<explain-card title="报告内容" tips="输入报告内容" v-model='content' :disabled='type!=1?true:false'></explain-card>
		<block v-if="type==1">
			<view class="uptitle">
				上传图片({{img.length}}-3张）
			</view>
			<view class="upimg">
				<image class="upimg_add" 
				@tap="previewImage(index)"
				:src="item" alt="" v-for="(item,index) in img" :key="index">
					<view class="upimg_add" @tap="upImg" v-if="">
						<image src="/static/img/icon6.png" alt="">
					</view>
			</view>
		</block>
		<block v-else>
			<view class="uptitle">
				图片
			</view>
		</block>
		
	</view>
</template>

<script>
	import explainCard from '@/components/explain_card.vue'
	export default {
		components: {
			explainCard
		},
		data() {
			return {
				//类型  1
				type:null,
				//图片上传的数组
				img: [],
				//
				content:'1111111111',
			}
		},
		onLoad(e) {
			this.type=e.type
		},
		methods: {
			//本地图片上传
			upImg() {
				uni.chooseImage({
					count: 3,
					success: (res) => {
						res.tempFilePaths.forEach(item => {
							this.img.push(item)
						})

					},
					fail: (err) => {
						uni.showToast({
							title: "图片上传失败",
							icon: 'none',
							duration: 1500
						})
					}
				})
			},
			//图片预览
			previewImage(index){
				uni.previewImage({
						current: index, //预览图片的下标
						urls: this.img //预览图片的地址，必须要数组形式，如果不是数组形式就转换成数组形式就可以
					})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		padding: 0 30rpx;
		box-sizing: border-box;
	}

	.upimg {}

	.upimg_add {
		width: 174rpx;
		height: 174rpx;
		background: #F9F9F9;
		border-radius: 20rpx;
		position: relative;
		margin-right: 40rpx;

		image {
			width: 36rpx;
			height: 36rpx;
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%);
		}
	}

	.uptitle {
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #7F8084;
		line-height: 40rpx;
		margin: 28rpx 0 30rpx;
	}
</style>
